<!-- 正文开始 -->
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <!-- 数据表格 -->
      <table id="dataTable1" lay-filter="dataTable"></table>
    </div>
  </div>
</div>
<script>
  layui.use(['layer', 'table', 'tableX', 'notice', 'xnUtil', 'laydate'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var table = layui.table;
    var tableX = layui.tableX;
    var admin = layui.admin;
    var form = layui.form;
    var notice = layui.notice;
    var xnUtil = layui.xnUtil;
    var laydate = layui.laydate;


    /* 渲染表格 */
    var insTb = tableX.render({
      elem: '#dataTable1',
      url: getProjectUrl() + 'judgementquestion/page',
      page: true,
      toolbar: ['<p>',
        '<button lay-event="add" perm-show="judgementquestion:add" class="layui-btn layui-btn-sm icon-btn"><i class="layui-icon">&#xe654;</i>选择</button>&nbsp;',
        '</p>'].join(''),
      cellMinWidth: 100,
      height:420,
      cols: [
        [
          {type: 'checkbox'},
          {field: 'title', title: '题目', sort: true},
          {field: 'type', title: '类型', sort: true},
          {field: 'state', title: '状态', sort: true},
          /*{field: 'remarks', title: '备注', sort: true},
          {title: '操作', toolbar: '#tableBar', align: 'center', width: 200, minWidth: 200}*/
        ]
      ],
      done: function(res, curr, count) {
        xnUtil.tableDone(insTb, res, curr, count);
      }
    });

    /* 表格搜索 */
    form.on('submit(tableSearch)', function (data) {
      insTb.reload({where: data.field, page: {curr: 1}});
      return false;
    });

    /* 表格头工具栏点击事件 */
    table.on('toolbar(dataTable)', function (obj) {
      if (obj.event === 'add') { // 添加
        var checkRows = table.checkStatus('dataTable1');
        admin.putLayerData('formOk', true, '#dataTable1');
        admin.putLayerData('resultData', checkRows.data, '#dataTable1');
        admin.closeDialog('#dataTable1');
      }
    });
  });
</script>
